import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  // 直接设置商城为首页
  {
    path: '/',
    name: 'Shop',
    component: () => import('@/views/Shop.vue'),
    meta: { title: '商城' },
    children: [
      {
        path: 'products',
        name: 'ProductList',
        component: () => import('@/views/Shop/ProductList.vue'),
        meta: { title: '商品列表' }
      },
      {
        path: 'myaccount',
        name: 'Myaccount',
        component: () => import('@/views/Shop/Myaccount.vue'),
        meta: { title: '我的账户' }
      },
      {
        path: 'cart',
        name: 'ShoppingCart',
        component: () => import('@/views/Shop/Cart.vue'),
        meta: { title: '购物车' }
      }
    ]
  },
  {
    path: '/edu',
    name: 'Education',
    component: () => import('@/views/Education.vue'),
    meta: { title: '农教' },
    children: [
      {
        path: 'courses',
        name: 'CourseList',
        component: () => import('@/views/Education/CourseList.vue'),
        meta: { title: '科普信息' }
      },
      {
        path: 'experts',
        name: 'ExpertList',
        component: () => import('@/views/Education/ExpertList.vue'),
        meta: { title: '专家库' }
      },
      {
        path: 'ai',
        name: 'Ai',
        component: () => import('@/views/Education/Ai.vue'),
        meta: { title: 'AI助手' }
      }
    ]
  },
  {
    path: '/community',
    name: 'Community',
    component: () => import('@/views/Community.vue'),
    meta: { title: '社区' },
    children: [
      {
        path: 'topics',
        name: 'TopicList',
        component: () => import('@/views/Community/TopicList.vue'),
        meta: { title: '话题列表' }
      },
      {
        path: 'evaluate',
        name: 'Evaluate',
        component: () => import('@/views/Community/Evaluate.vue'),
        meta: { title: '互动评价' }
      },
      {
        path: 'user/:id',
        name: 'UserProfile',
        component: () => import('@/views/Community/UserProfile.vue'),
        meta: { title: '用户主页' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router